<template>
  <div class="evaluate">
    <div class="top">
      <div class="title">
        评价
        <span class="number">{{ commentNum }}</span>
      </div>
      <div class="more">
        <span class="text" @click="moreEvalute">更多评价</span>
        <span class="arrow">></span>
      </div>
    </div>
    <div class="label__area">
      <div class="item" v-for="(item, index) in labelList" :key="index">{{ item }}</div>
    </div>
    <div class="list__msg">
      <evaluate-item-component
        v-for="(item, index) in evaluateList"
        :key="index"
        :showBtBorder="index < evaluateList.length - 1 ? true : false"
        :detail="item"
      />
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, PropType, ref } from 'vue'
import EvaluateItem from './EvaluateItem.vue'
import { EvaluateItemType } from '../utils/types'
export default defineComponent({
  name: 'Evaluate',
  emits: ['onMoreEvalute'],
  components: {
    'evaluate-item-component': EvaluateItem
  },
  props: {
    labelList: {
      type: Array,
      default: () => {
        return []
      }
    },
    evaluateList: {
      type: Array as PropType<EvaluateItemType[]>,
      default: () => {
        return []
      }
    },
    commentNum: {
      type: Number,
      default: () => {
        return 0
      }
    },
    currentId: {
      type: String,
      default: () => {
        return ''
      }
    }
  },
  setup(props, { emit }) {
    // 更多评价
    const moreEvalute = (): void => {
      emit('onMoreEvalute', props.currentId)
    }

    return {
      moreEvalute
    }
  }
})
</script>

<style lang="scss" scoped>
@import '@/style/variables.scss';
@import '@/style/mixins.scss';
.evaluate {
  width: 100%;
  box-sizing: border-box;
  background: white;
  box-shadow: 0px 2px 10px 0px rgba(93, 184, 255, 0.07);
  border-radius: 10px;
  padding: 15px 10px;
  .top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    .title,
    .number {
      font-size: 16px;
      font-weight: 600;
      color: #101736;
      line-height: 22px;
    }
    .number {
      padding-left: 5px;
    }
    .more {
      display: flex;
      align-items: center;
      .text {
        font-weight: 400;
        color: #101736;
        line-height: 17px;
      }
      .arrow {
        font-size: 16px;
        color: #a4a9b4;
        padding-left: 4px;
      }
    }
  }
  .label__area {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    .item {
      padding: 0 15px;
      height: 30px;
      line-height: 30px;
      border-radius: 15px;
      border: 1px solid #f5f5f7;
      background: #f5f5f7;
      margin-right: 10px;
      margin-bottom: 10px;
    }
    .active {
      background: rgba(64, 158, 255, 0.05);
      border: 1px solid #409eff;
    }
  }
}
</style>
